Skip to content

feat(sdk): add turn.failed system event support#119

Merged
james-rl merged 2 commits intomainfrom
james/sdk-turn-failed-events
May 6, 2026
Merged

feat(sdk): add turn.failed system event support#119
james-rl merged 2 commits intomainfrom
james/sdk-turn-failed-events

Conversation

@james-rl
Copy link
Copy Markdown
Contributor

@james-rl james-rl commented May 6, 2026

Summary

Adds a new turn.failed SystemEvent variant alongside the existing turn.started / turn.completed / broker.error events, with parsing, typed timeline guards, and ACP stream-level handling.

  • shared: new SystemEvent variant turn.failed, raw-event helper isTurnFailedAxonEvent, parser in tryParseSystemEvent, narrowed TurnFailedTimelineEvent + isTurnFailedEvent guard.
  • acp / claude: re-export the new type and guard from each module's timeline-event-guards barrel; refresh JSDoc on the system-event lists.
  • acp/axon-stream: when a turn.failed SYSTEM_EVENT arrives, reject every in-flight JSON-RPC request with a -32000 error carrying the failure message and event_type: \"turn.failed\" data, but keep the SSE loop alive so subsequent prompts on the same session can flow.
  • docs: update sdk/AGENTS.md system-event references.

Test plan

  • bun run check passes
  • bun run typecheck passes
  • bun run build passes
  • bun run test passes (500 tests, 19 files)
  • New unit tests cover parse paths, timeline guards (acp + claude + shared), and the four ACP axon-stream behaviours: single-pending rejection, multi-pending rejection, raw-payload fallback, stream-stays-alive after failure, and the no-op-when-no-pending case.

Made with Cursor

james-rl and others added 2 commits May 6, 2026 15:46
Adds a new `turn.failed` SystemEvent variant alongside the existing
`turn.started` / `turn.completed` / `broker.error` events, with parsing,
typed timeline guards, and ACP stream-level handling.

- shared: new `SystemEvent` variant `turn.failed`, raw-event helper
  `isTurnFailedAxonEvent`, parser in `tryParseSystemEvent`, narrowed
  `TurnFailedTimelineEvent` + `isTurnFailedEvent` guard.
- acp/claude: re-export the new type and guard from each module's
  timeline-event-guards barrel; refresh JSDoc on the system-event lists.
- acp/axon-stream: when a `turn.failed` SYSTEM_EVENT arrives, reject every
  in-flight JSON-RPC request with a `-32000` error carrying the failure
  message and `event_type: "turn.failed"` data, but keep the SSE loop
  alive so subsequent prompts on the same session can flow.
- docs: update `sdk/AGENTS.md` system-event references.

Co-authored-by: Cursor <cursoragent@cursor.com>
@james-rl james-rl requested a review from dines-rl May 6, 2026 22:56
@james-rl james-rl merged commit ef9ed7d into main May 6, 2026
5 checks passed
@james-rl james-rl deleted the james/sdk-turn-failed-events branch May 6, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants